using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;

namespace SAInterfaceLibrary
{
    /// <summary>
    /// Keeps a list of the items we need to create a project -- what gets given to control the creation.
    /// </summary>
    public class ProjectCreationInfo
    {
        /// <summary>
        /// Create a new project spec. Define a few defaults.
        /// </summary>
        public ProjectCreationInfo()
        {
            /// This is true for everything we do: it forces the ROOT build
            /// system to do an auto-config for itself.
            AddEnvVar("BUILDING_WITHIN_IDE", "yes");
        }

        private string _rootsys_dir;

        /// <summary>
        /// Directory where all of ROOT starts.
        /// </summary>
        public string ROOTSYSDirectory
        {
            get { return _rootsys_dir; }
            set { _rootsys_dir = value; }
        }

        private List<ProjectBuildConfigSpec> _build_configs = new List<ProjectBuildConfigSpec>();

        /// <summary>
        /// Collection of the various configs around.
        /// </summary>
        public ReadOnlyCollection<ProjectBuildConfigSpec> ProjectBuildConfigs
        {
            get { return _build_configs.AsReadOnly(); }
        }

        /// <summary>
        /// Clear out the project build config list that we are holding onto.
        /// </summary>
        public void ClearProjectBuildConfigs()
        {
            _build_configs.Clear();
        }

        /// <summary>
        /// Remember a new project configuration!
        /// </summary>
        /// <param name="projectBuildConfigSpec"></param>
        public void AddProjectBuildConfig(ProjectBuildConfigSpec projectBuildConfigSpec)
        {
            _build_configs.Add(projectBuildConfigSpec);
        }

        private List<EnvironmentVariable> _env_vars = new List<EnvironmentVariable>();

        /// <summary>
        /// Returns a list of all the environment variables.
        /// </summary>
        public ReadOnlyCollection<EnvironmentVariable> EnvironmentVariables
        {
            get
            {
                return _env_vars.AsReadOnly();
            }
        }

        /// <summary>
        /// Add a new env var to the list of the ones that we will have defined.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        public void AddEnvVar(string name, string value)
        {
            _env_vars.Add(new EnvironmentVariable(name, value));
        }

        private int _number_of_parallel_jobs = 0;

        /// <summary>
        /// Number of parallel make jobs - 0 means  no parallel building.
        /// </summary>
        public int NumberOfParallelMakeJobs
        {
            get { return _number_of_parallel_jobs; }
            set { _number_of_parallel_jobs = value; }
        }
    }
}
